#include<bits/stdc++.h>
using namespace std;
typedef int ll;
const ll N = 1e5 + 5;
ll T, n, m, L, V, p[N];
struct Node{
    ll d, v, a;
    Node(){}
    Node(ll d, ll v, ll a) : d(d), v(v), a(a){}
    bool operator < (const Node & B) const{
        return d < B.d;
    }
}A[N];
struct node{
    ll L, R;
    node(){}
    node(ll L, ll R) : L(L), R(R){}
    bool operator < (const node & B) const{
         if(L != B.L) return L < B.L;
         else return R < B.R;
    }
};
vector<node> vec;
bool checkA(){
    for(ll i = 1; i <= n; i ++) if(A[i].a != 0) return false;
    return true;
}
void sovleA(){
    ll sum = 0;
    for(ll i = 1; i <= n; i ++) if(A[i].v > V && A[i].d <= p[m]) sum ++;
    cout << sum << ' ' << m - (sum != 0) << endl;
}
bool checkB(){
    for(ll i = 1; i <= n; i ++) if(A[i].a <= 0) return false;
    return true;
}
void sovleB(){
    ll sum = 0;
    for(ll i = 1; i <= n; i ++) if(A[i].d <= p[m] && 1ll * A[i].v * A[i].v + 1ll * 2 * A[i].a * (p[m] - A[i].d) > 1ll * V * V) sum ++;
    cout << sum << ' ' << m - 1 << endl;
}
bool checkC(){
    for(ll i = 1; i <= n; i ++) if(A[i].a >= 0) return false;
    return true;
}
void sovleC(){
    vec.clear();
    ll sum = 0, cnt = 0;
    for(ll i = 1; i <= n; i ++){
        if(A[i].v * A[i].v + 2 * A[i].a * (p[1] - A[i].d) <= V * V || A[i].d > p[m]) continue;
        ll end = A[i].d - 1.0 * (A[i].v * A[i].v) / 2 / A[i].a;
        ll x = lower_bound(p + 1, p + m + 1, A[i].d) - p;
        ll y = lower_bound(p + 1, p + m + 1, end) - p - 1;
        vec.push_back(node(x, y)); 
        sum ++;  
    }
    if(sum == 0){
        cout << 0 << ' ' << m << endl;
        return ;
    }
    sort(vec.begin(), vec.end());
    ll L = vec[0].L, R = vec[0].R;
    for(ll i = 1; i < vec.size(); i ++){
        if(vec[i].L > R || vec[i].R < L){
            cnt ++;
            i ++;
            L = vec[i].L, R = vec[i].R;
        }
        else{
            L = max(L, vec[i].L);
            R = min(R, vec[i].R);
        }
    }
    cnt ++;
    cout << sum << ' ' << cnt << endl;
}
int main(){
    freopen("detect.in", "r", stdin);
    freopen("detect.out", "w", stdout);
	cin >> T;
	for(ll i = 1; i <= T; i ++){
	    scanf("%d%d%d%d", &n, &m, &L, &V);
	    for(ll i = 1; i <= n; i ++) scanf("%d%d%d", &A[i].d, &A[i].v, &A[i].a);
	    for(ll i = 1; i <= m; i ++) scanf("%d", &p[i]);
	    sort(p + 1, p + m + 1);
	    if(checkA()){
	        sovleA();
	        continue;
	    }
	    if(checkB()){
	        sovleB();
	        continue;
	    }
	    if(checkC()){
	        sovleC();
	        continue;
	    }
	}
	return 0;
}
